<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/jsp/common/headMain.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>角色管理</title>
  </head>
  		<script type="text/javascript">
		$(function(){
				jQuery("#_roleGrid").jqGrid({
				   	url: "${base}/role_getList",
					datatype: "json",
				   	colNames:['ID','角色名称','模块设置','功能设置','编辑'],
				   	colModel:[
				   		{name:'id',index:'id', width:55, align:'center',hidden:true},
				   		{name:'rolename', index:'rolename', align:'center'},
						{name:'modulesetup', index:'modulesetup', align:'center'},
				   		{name:'functionsetup', index:'functionsetup', align:'center'},
				   		{name:'edit', index:'edit', align:'center'},
				   	],
				   	width:_width_,
				   	height:230,
				   	rowNum:10,
				   	rowList:[10,20,30],
				   	pager: '#_roleBar',
				   	sortname: 'id',
				    viewrecords: true,
				    sortorder: "desc",
					multiselect: false,
					jsonReader: {
						repeatitems : false
					},
					rownumbers : true,
					caption: "角色管理",
					afterInsertRow : function(rowid, data) {
						$("#_roleGrid").jqGrid('setCell', rowid, 'modulesetup', '<span style="cursor:pointer;" onclick="_roleSetupModule(' + data.id + ');">模块设置</span>', {color : 'purple'});
						$("#_roleGrid").jqGrid('setCell', rowid, 'functionsetup', '功能设置');
						$("#_roleGrid").jqGrid('setCell', rowid, 'edit', '<span style="cursor:pointer;" onclick="_updateRole('+data.id+',\''+data.rolename+'\');">修改</span>|&nbsp;<span style="cursor:pointer;" onclick="_delRole(' + data.id + ');">删除</span>', {color:'green'});
					}
				});
				jQuery("#_roleGrid").jqGrid('navGrid','#_roleBar',{add : false, del : false, edit : false, refresh : true, search : false});
				jQuery.div.util.dialogInit("增加/编辑商家信息", "_addOrUpdateRole", 500, 200);
				jQuery.div.util.dialogInit("角色设置模块", "_roleSetupModule", 950, 360);
		});
		function _addOrUpdateRole(){
			//$("#_addOrUpdateRole").dialog("open");
			$('#_addOrUpdateRole').dialog('open').load('${base}/role_addOrUpdateRole', function(){
				jQuery.div.util.hideLoading();
			});
		}
		//角色设置模块
		function _roleSetupModule(roleId){
			$('#_roleSetupModule').dialog('open').load(jQuery.getBasePath() +'/role_roleSetupModule/'+roleId,function(){
				jQuery.div.util.hideLoading();
			});
		}
		function _updateRole(id,rolename){
			$('#_addOrUpdateRole').dialog('open').load('${base}/role_addOrUpdateRole', function(){
				$("#_update_id").val(id);
				$("#_update_rolename").val(rolename);
				$("#_update_description").val("描述");
				jQuery.div.util.hideLoading();
			});
		}
		//删除角色
		function _delRole(id) {
			if (confirm("删除角色吗？")) {
				$.post("${base}/role_deleteRole/" + id, 
					function(data) {
						if (data && data.success) {
							alert(data.msg);
							$("#_roleGrid").jqGrid('setGridParam',{url: '${base}/role_getList'}).trigger("reloadGrid");
						} else {
							alert(data.msg);
						}
					}, 
				"json");
			}
		}
		</script>
	<body>
	<table cellpadding="0" cellspacing="0" border="0" width="99%" style="height:100%;">
		<tr><td style="height:10px; overflow:hidden;" colspan="2"></td></tr>
		<tr>
			<!--右边内容-->
			<td width="*" valign="top" class="contList">
					<!-- begin -->
					<div id="_roleManagerDiv">
							<div class="mainInfo">
								<!-- div class="subScroll" id="subScroll">< !-- 滚动条 -- >
									<div class="searchList">
										<ul>
											<li><span>XXX：</span>
												<input type="text" id="" name="" />
											</li>
											<li><span>XX：</span>
												<input type="text" id="" name="" /
											</li>
										</ul>
										<div class="clearfloat"></div>
										<div class="btn">
											<strong><em class="searchIcon"></em><input type="button" value="查询" class="btn" id="" /></strong>
											<strong><em class="clearIcon"></em><input type="button" value="清空查询" class="btn"  onclick="" /></strong>
										</div>
										<div class="searchListBg"></div>
									</div> -->
									<div class="mainTable">
										<table id="_roleGrid"></table><!-- 显示列表内容 -->
										<div id="_roleBar"></div>
										<div class="contBtn btn">
											<strong><em class="addIcon"></em><input type="button" value="增加角色" class="btn" onclick="_addOrUpdateRole();"/></strong>
										</div>
											<div class="minwidth_div"></div>
										</div>
									</div>
								</div>
							</div>
					</div>
					<!-- end  -->
				
			</td>
	</table>
	</body>
</html>
<!-- 增加角色 弹出页 --------------------------------------------------------------------------->
<div id="_addOrUpdateRole"></div>
<!--角色设置模块-->
<div id="_roleSetupModule"></div>
	
